OTConnect
Requests a connection to a remote peer.C INTERFACE
OSStatus OTConnect(EndpointRef ref, TCall* sndCall, TCall* rcvCall);C++ INTERFACE
OSStatus TEndpoint::Connect(TCall* sndCall, TCall* rcvCall);PARAMETERS
ref
- The endpoint reference of the endpoint initiating the connection.
sndCall
- A pointer to a
TCall
structure (page 3-62) that specifies the address of the remote peer, any data transmitted when establishing a connection, and any options for this connection.rcvCall
- A pointer to a
TCall
structure (page 3-62) that specifies the address of the peer that has accepted the connection, the value of options proposed using thesndCall
parameter, and any data transmitted by the peer accepting the connection.- This parameter is only meaningful for synchronous calls to the
OTConnect
function.DESCRIPTION
If the endpoint is in synchronous mode, theOTConnect
function returns after the connection is established and fills in the fields of theTCall
structure (referenced by thercvCall
parameter) with the actual values associated with this connection. These might be different from the values you specified using thesndCall
parameter.If the
OTConnect
function returns with thekOTLookErr
result, this might be either because of a pendingT_LISTEN
orT_DISCONNECT
event. That is, either a connection request from another endpoint has interrupted execution of the function, or the remote endpoint has rejected the connection. If you don't have a notifier installed, you can call theOTLook
function to identify the event that caused thekOTLookErr
result. If the event isT_LISTEN
, you must accept or reject the incoming request and then continue processing theOTConnect
function by callingOTRcvConnect
. If the event isT_DISCONNECT
, you must call theOTRcvDisconnect
function to clear the error condition--that is, to deallocate memory and place the endpoint in the correct state.If the endpoint is in asynchronous mode, the
OTConnect
function returns before the connection is established with akOTNoDataErr
result to indicate that the connection is in progress. When the connection is established, the endpoint provider calls your notifier, passingT_CONNECT
for thecode
parameter. In response, you must call theOTRcvConnect
function to read the connection parameters that would have been returned using thercvCall
parameter if the endpoint were in synchronous mode.It is possible that the remote address returned in the
addr
field of thercvCall
parameter is not the same as the address you requested using thesndCall->addr
field. This happens when the connection is accepted for a different endpoint than the one receiving the connection request.If the
OTConnect
function returns a result other thankOTNoDataErr
, then the connection attempt has not been initiated and no events will be received.SPECIAL CONSIDERATIONS
Not all endpoints support the sending of data with a connection request. Examine theconnect
field of theTEndpointInfo
structure for the endpoint to determine if the endpoint supports the sending of data and to determine the maximum size of the data.VALID STATES
T_IDLE
SEE ALSO
You can use theOTLook
function (page 3-85) to retrieve a pending
asynchronous event.You use a
TCall
structure (page 3-62) to specify the address of the remote peer, any data transmitted when establishing a connection, and any options for the connection.You use the
OTRcvDisconnect
function (page 3-151) to acknowledge that your request for a connection has been rejected.For information on how to use this function with a TCP/IP protocol, see page 8-17 in the TCP/IP chapter.
For information on how to use this function with AppleTalk protocols, see page 13-10 in the ADSP chapter and page 15-9 in the PAP chapter.
You examine the
connect
field of theTEndpointInfo
structure (page 3-48) to determine whether your endpoint supports the sending of data with a connection request.